/* eslint-disable */
'use strict';

module.exports = app => {
  const { STRING, DATE, BIGINT } = app.Sequelize;

  const Comment = app.model.define('comment', {
    id: { type: BIGINT, primaryKey: true, autoIncrement: true },
    user_id: {
      type: BIGINT,
      allowNull: false,
    },
    outfit_id: {
      type: BIGINT,
      allowNull: false,
    },
    content: {
      type: STRING(255),
      allowNull: false,
    },
    parent_id: {  
      type: BIGINT,
      allowNull: true,
    },
    created_at: DATE,
    updated_at: DATE,
  }, {
    tableName: 't_comment',
  });

  Comment.associate = function() {
  app.model.Comment.hasMany(app.model.Comment, {  // 关联回复
    foreignKey: 'parent_id',
    as: 'replies',
  });
}
  return Comment;
};
